package com.haoshuang.zhouzhoubang.ui.page.mine.notice.list

import com.haoshuang.zhouzhoubang.model.api.ApiRepo
import com.haoshuang.zhouzhoubang.model.bean.HomeDataBean
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.net.netRequest
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData

class NoticeListViewModel : BaseViewModel() {

    /**
     * 获取公告列表
     */
    val getNoticeListData = StatefulMutableLiveData<MutableList<HomeDataBean.SystemNotice>>()
    fun getNoticeList() = netRequest {
        start { getNoticeListData.value = StateData.Loading }
        request { ApiRepo.getNoticeList()  }
        success { getNoticeListData.value = StateData.Success(it.data) }
        error { code, msg ->
            getNoticeListData.value = StateData.Error(code, msg)
        }
    }

}